package com.iot08.api.service;

import com.iot08.api.vo.request.FeedbackReqVO;
import com.iot08.common.entity.app.Feedback;
import com.iot08.common.service.base.BaseService;
import com.iot08.common.utils.StringUtil;
import com.iot08.common.utils.response.ResponseMap;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @version 1.0
 * @Description: 问题反馈记录业务
 * @author: Rock
 * @time: 2021/1/5 16:40
 */
@Slf4j
@Service
public class FeedbackService extends BaseService<Feedback> {

    /**
     * 反馈问题
     *
     * @param vo
     * @time: 2021/1/5 16:47
     * @author: Rock
     * @version 1.0
     */
    public ResponseMap add(FeedbackReqVO vo) {
        Feedback feedback = new Feedback();
        feedback.setContent(vo.getContent());
        feedback.setCreateTime(new Date());
        if (StringUtil.isNotBlank(vo.getEmail())) {
            feedback.setEmail(vo.getEmail());
        }
        if (StringUtil.isNotBlank(vo.getName())) {
            feedback.setName(vo.getName());
        }
        if (StringUtil.isNotBlank(vo.getOpenid())) {
            feedback.setOpenid(vo.getOpenid());
        }
        this.save(feedback);
        return ResponseMap.success();
    }
}
